﻿cmake_minimum_required(VERSION 2.8)

project(myapp)

set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}")

find_package(Mylib REQUIRED)

add_executable(${PROJECT_NAME} main.cxx)
target_include_directories(${PROJECT_NAME} PRIVATE ${Mylib_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} ${Mylib_LIBRARY})

add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD              # Adds a post-build event to Target
        COMMAND ${CMAKE_COMMAND} -E copy_if_different                 # which executes "cmake - E copy_if_different..."
        ${${USER_DEFINE_MODULE_NAME}-install}/bin/Mylib.dll      # <--this is in-file
        $<TARGET_FILE_DIR:${PROJECT_NAME}>)                           # <--this is out-file path
        